package com.haoze.nurseapp.dao;

import com.haoze.nurseapp.dto.DrugApplyDetailDTO;
import com.haoze.nurseapp.dto.DrugApplyMainDTO;
import com.haoze.nurseapp.model.DrugApplyDetailEntity;
import com.haoze.nurseapp.model.DrugApplyMainEntity;
import com.haoze.nurseapp.vo.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author lufq
 * @date 2020/9/17
 */
public interface MedicineApplyMapper {
    //病区领药
    List<Map<String,Object>> wardWaitMedicineList(@Param("wardDeptId") String wardDeptId,@Param("inpatNums") String[] inpatNums);
    List<MedicineApplyByInpatVo> wardWaitMedicineListGroup(@Param("wardDeptId") String wardDeptId, @Param("inpatNums") String[] inpatNums);
    List<MedicineApplyByInpatVo> queryPatientInfoByWardDeptId(@Param("wardDeptId") String wardDeptId, @Param("inpatNums") String[] inpatNums);

    //根据医嘱获取执行时间
    String queryExecuteTimeByInpatorderdataId(@Param("inpatorderdataId") String inpatorderdataId);

    //根据病区Id获取药房列表
    List<Map<String,String>> queryPharmacyByWardDeptId(@Param("wardDeptId") String wardDeptId,@Param("flag") String flag);

    //根据病区Id获取药房列表
    Map<String,String> queryEmergencyPharmacyByWardDeptId(@Param("wardDeptId") String wardDeptId,@Param("flag") String flag);

    //门诊领药
    //List<Map<String,Object>> outpatientDepartmentWaitMedicineList(@Param("wardDeptId") String wardDeptId,@Param("inpatNums") String[] inpatNums);
    List<MedicineApplyByInpatVo> outpatientDepartmentWaitMedicineList(@Param("wardDeptId") String wardDeptId,@Param("inpatNums") String[] inpatNums);

    //处方处理本
    //List<Map<String,Object>> prescriptionWaitMedicineList(@Param("wardDeptId") String wardDeptId,@Param("inpatNums") String[] inpatNums);
    List<PrescriptionMedicineApplyByInpatVo> prescriptionWaitMedicineList(@Param("wardDeptId") String wardDeptId, @Param("inpatNums") String[] inpatNums);
    //PrescriptionMedicineApplyByInpatVo
    int insertDrugApplyMain(DrugApplyMainDTO drugApplyMainEntity);
    //领药申请明细表
    int insertDrugApplyDetail(List<DrugApplyDetailEntity> drugApplyDetailEntities);
    //门诊领药待接收列表
    //List<Map<String,Object>> outpatientDepartmentToBeReceivedMedicineList(@Param("wardDeptId") String wardDeptId);
    List<OutpatientReceiveMedicineApplyByInpatVo> outpatientDepartmentToBeReceivedMedicineList(@Param("wardDeptId") String wardDeptId,@Param("inpatNums") String[] inpatNums);
    //处方处理本待接收列表
    //List<Map<String,Object>> prescriptionToBeReceivedMedicineList(@Param("wardDeptId") String wardDeptId);
    List<PrescriptionReceivedMedicineApplyByInpatVo> prescriptionToBeReceivedMedicineList(@Param("wardDeptId") String wardDeptId,@Param("pharmacy") String pharmacy,@Param("inpatNums") String[] inpatNums);
    //病区领药待接收列表
    //List<Map<String,Object>> wardToBeReceivedMedicineList(@Param("wardDeptId") String wardDeptId);
    List<ReceiveMedicineApplyByInpatVo> wardToBeReceivedMedicineList(@Param("wardDeptId") String wardDeptId);

    List<DrugApplyMainEntity> queryDrugApplyMainList(@Param("applyIds") List<String> applyIds);

    int updateDrugApplyMain(DrugApplyMainEntity drugApplyMainEntity);

    int updateDrugApplyDetail(@Param("applyId") String applyId,@Param("applyStatus") String applyStatus);

    Map<String,String> queryPatientPrescDrugInfo(@Param("prescdrugId") String prescdrugId);

    Map<String,String> queryTmpPatientOrders(@Param("inpatorderdataId") String inpatorderdataId);

    //获取药房code
    String queryPharmacyCodeById(@Param("pharmacyId") String pharmacyId);

    List<DrugApplyDetailEntity> queryDrugApplyDetailList(@Param("applyId") String applyId);

    List<String> queryDrugApplyMainByStatus();

    int updateDrugApplyMainStatus(@Param("applyIds") List<String> applyList);

    int updateDrugApplyDetailStatus(@Param("applyIds") List<String> applyList,@Param("status") String status);

    List<Map<String,String>> queryTmpPatientPresc(@Param("prescId") String prescId);
    List<Map<String,String>> queryTmpPatientPresc2(@Param("prescId") String prescId);

    Map<String,String> queryTmpPatientPrescDrug(@Param("prescDrugId") String prescDrugId);

    DrugApplyMainEntity queryDrugApplyMainInfo(@Param("applyId") String applyId);

    List<DrugApplyDetailDTO> queryDrugApplyDetailListByInpatorderdataId(@Param("inpatorderdataIds") List<String> inpatorderdataIds);

    int deleteDrugApplyDetailByInpatorderdataId(@Param("inpatorderdataIds") List<String> inpatorderdataIds,@Param("applyStatus") String applyStatus,@Param("applyId") String applyId);

    int updateDrugApplyMainByApplyIds(@Param("applyStatus") String applyStatus,
                                      @Param("deletePersonId") String deletePersonId,
                                      @Param("applyIds") List<String> applyIds);

    String queryPatientInHospitalByInpatNum(@Param("inpatNum") String inpatNum);

    List<String> queryDrugApplyMainByStatus4();

    int insertTmpDrugApplyMain(@Param("primaryId") String primaryId,@Param("applyId") String applyId);

    Map<String,String> queryTmpDrugApplyMain(@Param("primaryId") String primaryId);

    int updateTmpDrugApplyMain(@Param("primaryId") String primaryId,@Param("applyId") String applyId);

    List<Map<String,String>> queryPatientPresc(@Param("inpatNum") String inpatNum);

    List<Map<String,String>> queryPatientPrescDetail(@Param("prescNums") String[] prescNums);
    List<Map<String,String>> queryDrugApplyMainByReqId(@Param("prescNums") List<String> prescNums);

    int updateDrugApplyMainInfo(@Param("prescNums") List<String> prescNums,@Param("user") String user);
    int updateDrugApplyDetailInfo(@Param("applyDetailId") String applyDetailId,@Param("user") String user,@Param("performResult") String performResult);

    int updatePatientPresc(@Param("prescNums") String[] prescNums,@Param("nurseId") String nurseId);

    String getPersonIdByUserId(@Param("userId") String userId);

    List<Map<String,String>> queryPatientPrescNurseId(@Param("prescNums") String[] prescNums);
}
